JBoss Community Archive (Read Only)

Infinispan 5.1

Configuring Cache declaratively

One of the major goals of Infinispan is to aim for zero configuration. A simple XML configuration file containing nothing more than a single infinispan element is enough to get you started. The configuration file listed below provides sensible defaults and is perfectly valid.

<infinispan />
However, that would only give you the most basic, local mode, non-clustered cache. Non basic configurations are very likely to use customized global and default cache elements.

Declarative configuration is the most common approach to configuring Infinispan cache instances. In order to read XML configuration files one would typically construct an instance of CacheManager by pointing to an XML file containing Infinispan configuration. Once configuration file is read you can obtain reference to the default cache instance.

CacheManager manager = new DefaultCacheManager("my-config-file.xml");
Cache defaultCache = manager.getCache();
or any other named instance specified in "my-config-file.xml".
Cache someNamedCache = manager.getCache("someNamedCache");
Every time you define <namedCache> element in XML configuration file, in addition to <default> cache element, you are effectively configuring additional caches whose settings are inheriting and/or overriding the default cache.

Refer to Infinispan configuration reference for more details. If you are using XML editing tools for configuration writing you can use provided Infinispan schema to assist you.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 09:16:19 UTC, last content change 2012-01-18 10:27:18 UTC.